package me.zk.practice1.hw;

import java.util.Scanner;

/**
 * @author zhangkai
 * @date 2023/8/11 17:27
 */
public class HWBJJ02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();

        int n = Integer.parseInt(scanner.nextLine());

        for (int i = 0; i < n; i++) {
            s = String.valueOf(getMin(s));
        }
        System.out.println(s);
    }

    public static int getMin(String s){

        int min = Integer.parseInt(s.substring(1));

        for (int i = 1; i < s.length(); i++) {
            int j = Integer.parseInt( s.substring(0,i)+s.substring(i+1));
            min = Math.min(min,j);
        }
        return min;
    }

}
